package test.flow;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import hyl.base.flow.Flow;
import hyl.base.flow.Track;
import hyl.base.flow.express.Depend;
import hyl.core.MyFun;

public class testExpr {
	// static CTracks t = new CTracks("状态1,状态2,状态3,状态4,审批1,审批2,审批3");

	// (状态2=y&状态3=1)|(状态3>2&状态3<9)|(状态2@1,2,3,4)

	public static void testor(Flow model) {
		Depend c = Depend.getInstance("状态2|状态3=1");
		String flowid=MyFun.getUUID();
		Track tracks = model.getTrkInstance(flowid);
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '1');
		System.out.println("t | t=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '1');
		System.out.println("f | t=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '2');
		System.out.println("t | f=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		System.out.println("f | f=" + c.judge(tracks));
	}

	public static void testand(Flow model) {
		Depend c = Depend.getInstance("状态2=1&状态3=1");
		Track tracks = model.getTrkInstance("1000001");
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '1');
		System.out.println("t & t=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		System.out.println("t & f=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '1');
		System.out.println("f & t=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '2');
		System.out.println("f & f=" + c.judge(tracks));
	}

	public static void testand3(Flow model) {
		Track tracks = model.getTrkInstance("1000001");
		Depend c = Depend.getInstance("(状态2=1)&(状态3=1)");
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '1');
		System.out.println("f & t=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		System.out.println("t & f=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '1');
		System.out.println("f & t=" + c.judge(tracks));

		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '2');
		System.out.println("t & f=" + c.judge(tracks));
	}

	public static void testor3(Flow model) {
		Track tracks = model.getTrkInstance("1000001");
		Depend c = Depend.getInstance("(状态2=1)|(状态3=1)");
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '1');
		System.out.println("f | t=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		System.out.println("t | f=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '1');
		System.out.println("f | t=" + c.judge(tracks));

		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '2');
		System.out.println("t | f=" + c.judge(tracks));
	}

	public static void testand4(Flow model) {
		Track tracks = model.getTrkInstance("1000001");
		Depend c = Depend.getInstance("((状态2=1)|状态3=1&状态1=0)");
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '1');
		System.out.println("t & t=" + c.judge(tracks));
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		System.out.println("t & f=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '1');
		System.out.println("f & t=" + c.judge(tracks));
		tracks.setMark("状态2", '2');
		tracks.setMark("状态3", '2');
		System.out.println("t & f=" + c.judge(tracks));

		System.out.println("t  &f |t=" + (true & false | true));
	}

	public static void test5(Flow model) {
		Track tracks = model.getTrkInstance("1000001");
		Depend c = Depend.getInstance("状态1=1&状态2=1|状态3=1&状态3=1|状态4=1");
		tracks.setMark("状态1", '2');
		tracks.setMark("状态2", '1');
		tracks.setMark("状态3", '2');
		tracks.setMark("状态4", '1');
		System.out.println("result=" + c.judge(tracks));
		System.out.println("checked=" + (false & true | false & false | true));
	}

	public static void test6(Flow model) {
		Track tracks = model.getTrkInstance("1000001");
		Depend c = Depend.getInstance("状态2=2&状态1=2|(状态3>2&状态3<9)|(状态1@1,2,3,4)");

		tracks.setMark("状态1", 'T');
		tracks.setMark("状态3", '4');

		System.out.println("result=" + c.judge(tracks));
		System.out.println("checked=" + (false & false | (true & true) | (false)));
	}

}
